﻿package plugin.shop
{
    import com.core.*;
    import flash.events.*;
    import plugin.shop.component.*;
    import uiresource.shop.*;

    public class ShopUICtrl extends ShopUI
    {
        private var _close:Function;
        public var mPage1:NewSellPage;
        public var mPage2:NewReBayPage;
        public var mPage3:NewXlPage;
        private var _npcid:int = 0;

        public function ShopUICtrl(param1:Function)
        {
            this._close = param1;
            return;
        }// end function

        override protected function initializeView() : void
        {
            super.initializeView();
            var _loc_1:* = Control.create(ShopControl, this);
            ModelProxy.addObserver("shop", _loc_1);
            btn1.selected = true;
            btn1.addEventListener(MouseEvent.CLICK, this.onClicked1);
            this.mPage1 = new NewSellPage();
            this.mPage1.x = 9;
            this.mPage1.y = 78;
            if (this._npcid > 0)
            {
                this.mPage1.npcid = this._npcid;
            }
            this.mPage1.visible = true;
            this.addChild(this.mPage1);
            closeBtn.addEventListener(MouseEvent.CLICK, this.onClose);
            return;
        }// end function

        public function openRefresh() : void
        {
            btn1.selected = true;
            this.mPage1.visible = true;
            panel.visible = true;
            panel1.visible = false;
            return;
        }// end function

        private function onClicked1(event:MouseEvent) : void
        {
            btn1.selected = true;
            panel.visible = true;
            panel1.visible = false;
            return;
        }// end function

        private function onClicked2(event:MouseEvent) : void
        {
            btn1.selected = false;
            panel.visible = false;
            panel1.visible = true;
            return;
        }// end function

        public function set npcid(param1:int) : void
        {
            this._npcid = param1;
            if (this.mPage1)
            {
                this.mPage1.npcid = param1;
            }
            return;
        }// end function

        public function get npcid() : int
        {
            return this._npcid;
        }// end function

        private function onClose(event:MouseEvent) : void
        {
            this.close();
            return;
        }// end function

        private function close() : void
        {
            ModelProxy.change("mainview", "complateclose", "fshop");
            ModelProxy.change("bag", "closesell", null);
            ModelProxy.change("plugin", "close", "shop");
            return;
        }// end function

    }
}
